package com.xiaoma.vpa;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import com.xiaoma.drools.DroolsStateSession;

import ch.qos.logback.classic.android.BasicLogcatConfigurator;


/**
 * Example showing loading a KieContainer with drools-compiler dependency.
 */
public class MainActivity extends Activity implements View.OnClickListener {
    DroolsStateSession droolsStateSession;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        BasicLogcatConfigurator.configureDefaultContext();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        droolsStateSession = new DroolsStateSession(this);
        findViewById(R.id.stateful_btn).setOnClickListener(this);
        findViewById(R.id.stateless_btn).setOnClickListener(this);
        findViewById(R.id.multi_stateful_btn).setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.stateful_btn:
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        droolsStateSession.stateFulSession();
                    }
                }).start();
                break;
            case R.id.stateless_btn:
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        droolsStateSession.stateLessSession();
                    }
                }).start();
                break;
            case R.id.multi_stateful_btn:
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        droolsStateSession.multiDrl();
                    }
                }).start();
                break;
        }
    }
}
